package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjawardoff;
import com.chezhujie.www.persistence.CzjawardoffMapper;
import com.sys.core.page.Pagination;
import com.sys.core.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("czjawardoffService")
public class CzjawardoffService {
	@Autowired
	private CzjawardoffMapper czjawardoffMapper;

	/**
	 * 查询czj_awardon 奖品线上列表全部
	 * @return
	 */
	public  List<String> getCzjawardoffListStringALL() {
		List<String> list=	czjawardoffMapper.getCzjawardoffListStringALL();
		return list;		
	}	
	
	/**
	 * 查询某个czj_advertisementImg  图片广告queryImgOrder
	 * @param param
	 * @return
	 */
	public Czjawardoff queryImgOrder(Map<String,Object> param) {
		return czjawardoffMapper.queryImgOrder(param);
	}		
	
	/**
	 * 查询某个czj_awardoff 奖品线上
	 * @param param
	 * @return
	 */
	public Czjawardoff getCzjawardoff(Map<String,Object> param) {
		return czjawardoffMapper.getCzjawardoff(param);
	}
   
	/**
	 * 查询czj_awardoff 奖品线上列表
	 * @return
	 */
	public Map<String,Object> getCzjawardoffList(Map<String,Object> param) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		returnMap.put("totalCounts", czjawardoffMapper.getTotalRows(param));
		returnMap.put("list", czjawardoffMapper.getCzjawardoffList(param));
		return returnMap;
	}
   
	/**
	 * 查询czj_awardoff 奖品线上列表
	 * @return
	 */
	public  Pagination getCzjawardoffList(Map<String,Object> param,int pageSize,Integer pageNo,String order,String sort) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		p.setOrder(order);
		p.setSort(sort);
		param.putAll(p.toMap());
		int count=czjawardoffMapper.getTotalRows(param);
		List<Czjawardoff> list=	czjawardoffMapper.getCzjawardoffList(param);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
		
	}
      
	/**
	 * 新增czj_awardoff 奖品线上
	 * @param czjawardoff
	 * @param param
	 */
	@Transactional
	public void insertCzjawardoff(Czjawardoff czjawardoff) {
		czjawardoff.setAwardoffId(UUIDUtils.getUUID());
		czjawardoffMapper.insertCzjawardoff(czjawardoff);
	}
   
	/**
	 * 编辑czj_awardoff 奖品线上
	 * @param czjawardoff
	 * @param param
	 */
	@Transactional
	public void updateCzjawardoff(Czjawardoff czjawardoff) {
		czjawardoffMapper.updateCzjawardoff(czjawardoff);
	}
   
	/**
	 * 删除czj_awardoff 奖品线上
	 * @param param
	 */    
	@Transactional
	public void deleteCzjawardoff(List<String> awardoffIdList) {
		for(String awardoffId: awardoffIdList){
	  		Map<String,Object> param = new HashMap<String,Object>();
	  		param.put("awardoffId", awardoffId);
	 	   czjawardoffMapper.deleteCzjawardoff(param);	  		
		}
	}


}